package com.huawo.opensdk.manager;

import androidx.annotation.Nullable;
import com.huawo.sdk.bluetoothsdk.error.ErrorCode;

public class SDKInvokeException extends Exception {
    public static final int CODE_UNKNOWN = -1;
    public static final int CODE_BLUETOOTH_OFF = ErrorCode.BLUETOOTH_OFF;
    public static final int CODE_DISCONNECTED = ErrorCode.DISCONNECTED;
    public static final int CODE_WORKOUT_ING = 50;
    public static final int CODE_CALLING_OTA_ERROR = ErrorCode.CALLING_OTA_ERROR;

    public final int code;

    public SDKInvokeException(int code) {
        super("[" + code + "]");
        this.code = code;
    }

    public SDKInvokeException(int code, String message) {
        super("[" + code + "]" + message);
        this.code = code;
    }

    public SDKInvokeException(int code, String message, Throwable cause) {
        super("[" + code + "]" + message, cause);
        this.code = code;
    }

    public SDKInvokeException(int code, Throwable cause) {
        super("[" + code + "]", cause);
        this.code = code;
    }

    @Nullable
    public Integer getStringRes() {
        if (64 == code) {//运动中
            return code;
        } else if (65 == code) { //充电中
            return code;
        } else if (37 == code) {//手表空间不足
            return code;
        } else if (6 == code || 38 == code) {//蓝牙断链或同步超时
            return code;
        }else if (58 == code) { // BT通话中
            return code;
        }else if (66 == code) { // 省点模式中
            return code;
        }else if (67 == code) { // 番茄钟模式中
            return code;
        }else if (68 == code) {// OTA模式中
            return code;
        }else if (69 == code) {// OTA表盘中
            return code;
        }else if (70 == code) {// OTA音乐中
            return code;
        }else if (71 == code) {// OTA照片中
            return code;
        }else if (999 == code){// OTA中不能再其他OTA了
            return code;
        }
        return 0;   }

}